package org.gw.ylc.base.data;

import org.hibernate.engine.query.spi.EntityGraphQueryHint;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.hql.spi.FilterTranslator;
import org.hibernate.hql.spi.QueryTranslator;
import org.hibernate.hql.spi.QueryTranslatorFactory;

import java.util.Map;

@SuppressWarnings("rawtypes")
public class QueryInspector implements QueryTranslatorFactory {

	private static final long serialVersionUID = 1L;

	@Override
	public QueryTranslator createQueryTranslator(String queryIdentifier, String queryString, final Map filters,
			final SessionFactoryImplementor factory, EntityGraphQueryHint entityGraphQueryHint) {
		return new PermissionedQueryTranslator(queryIdentifier, queryString, filters, factory, entityGraphQueryHint);
	}

	@Override
	public FilterTranslator createFilterTranslator(String queryIdentifier, String queryString, Map filters,
			SessionFactoryImplementor factory) {
		return new PermissionedQueryTranslator(queryIdentifier, queryString, filters, factory);
	}

}
